import 'virtual:uno.css';
import 'nprogress/nprogress.css';
// import '@/assets/styles/main.less';
import { createApp } from 'vue';
import { createPinia } from 'pinia';
import NProgress from 'nprogress';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
import { createDiscreteApi } from 'naive-ui';
import '@/router/permission';
import router from './router';
import App from './App.vue';
import { setupDirectives } from './directives';

async function bootstrap() {
  dayjs.extend(utc);
  dayjs.extend(timezone);
  // 设置默认时区为中国
  dayjs.tz.setDefault('Asia/Shanghai');

  const app = createApp(App);
  const { message } = createDiscreteApi(['message']); // 这里拿到全局 message
  app.config.globalProperties.$message = message; // 挂到全局

  app.use(createPinia());
  app.use(router);

  // 等待路由就绪
  await router.isReady();

  setupDirectives(app);

  NProgress.configure({ showSpinner: false }); // 配置 NProgress

  app.mount('#app');
}

bootstrap();
